class Solution {
    public int search(int[] nums, int target) {
        int left = 0;
        int rigth = nums.length - 1;
        int num = 0;
        if(nums == null || nums.length == 0) {
            return num;
        }
        while(left < rigth) {
            if(nums[left] == target) {
                num++;
            }
            if(nums[rigth] == target) {
                num++;
            }
            left++;
            rigth--;
        }
        if(left == rigth && nums[left] == target) {
            num++; 
        }
        return num;
    }
}